﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Cliente
{
    public partial class cambioClave : Form
    {
        String infoCuenta = "";

        public cambioClave(String infoCuenta)
        {
            InitializeComponent();
            this.infoCuenta = infoCuenta;
            labelClave.Visible = false;
            textClave2.Visible = false;
        }

        private void cambioClave_Load(object sender, EventArgs e)
        {

        }

        private void agregar(String num) {
            if (textClave1.Text.Length<10)
                textClave1.Text += num;        
        }

        private void num1_Click(object sender, EventArgs e)
        {
            agregar("1");
        }

        private void num2_Click(object sender, EventArgs e)
        {
            agregar("2");
        }

        private void num3_Click(object sender, EventArgs e)
        {
            agregar("3");
        }

        private void num4_Click(object sender, EventArgs e)
        {
            agregar("4");
        }

        private void num5_Click(object sender, EventArgs e)
        {
            agregar("5");
        }

        private void num6_Click(object sender, EventArgs e)
        {
            agregar("6");
        }

        private void num7_Click(object sender, EventArgs e)
        {
            agregar("7");
        }

        private void num8_Click(object sender, EventArgs e)
        {
            agregar("8");
        }

        private void num9_Click(object sender, EventArgs e)
        {
            agregar("9");
        }

        private void num0_Click(object sender, EventArgs e)
        {
            agregar("0");
        }

        private void labelBorrar_Click(object sender, EventArgs e)
        {
            if (textClave1.Text.Length!=0)
                textClave1.Text = textClave1.Text.Substring(0, textClave1.Text.Length - 1);
        }

        private void cancelar_Click(object sender, EventArgs e)
        {
            new Principal().Visible = true;
            this.Visible = false;
        }

        private void labelContinuar_Click(object sender, EventArgs e)
        {
                if (textClave1.Text.Length == 0)
                    return;
                if (textClave1.Text.Length != 10)
                {
                    int longitud = 10 - textClave1.Text.Length;
                    for (int i = 0; i < longitud; i++)
                    {
                        textClave1.Text += "*";
                    }
                }
                cliente.enviar("M" + textClave1.Text + infoCuenta.Substring(10, 10));
                MessageBox.Show("Operacion Exitosa");
                new Principal().Visible = true;
                this.Visible = false;
            
        }
    }
}
